<template>
      <el-select
        v-model="cur_value"
        placeholder="请选择部门"
        clearable
      >
        <el-option
          v-for="item in departmentAry"
          :key="'departmentAry' + item.key"
          :label="item.name"
          :value="item.key"
        />
      </el-select>
</template>

<script>
import {
  getDepartment
} from "@/api/org_team_members";
import g from "@/utils/utilFn";
export default {
  name: "departmentSelect",
  props: {
    value: String,
  },
  data() {
    return {
      departmentAry: [],
    };
  },
  computed: {
    cur_value: {
      get() {
        return this.value;
      },
      set(val) {
        this.$emit("change", val);
      },
    },
  },
  created() {
    this.initDepartment();
  },
  methods: {
    initDepartment() {
      return getDepartment().then((response) => {
        console.log(response);
        var data = g.Copy(response.data);
        this.department_groupAry =g.Copy(data);
        var departmentAry = g.removeRepeatAttr(data, "department");
        g.each(departmentAry, function (it) {
          it.key = it.department;
          it.name = it.department;
        });
        this.departmentAry = departmentAry;          
      });
    },
  },
};
</script>

